package jinyilw.tools.net.dev;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public final class NetworkRawPacket extends NetworkPacket
{
	public static short ID = Short.MIN_VALUE + 150; // the id for raw packet

	private byte[] packet;

	public NetworkRawPacket(byte[] packet)
	{
		this.packet = packet;
	}

	public short getID()
	{
		return NetworkRawPacket.ID;
	}

	public void setId(short id)
	{
		throw new UnsupportedOperationException(
				"To change NetworkRawPacket ID, use NetworkRawPacket.ID = new_id instead.");
	}

	public byte[] getPacket()
	{
		return this.packet;
	}

	public void setPacket(byte[] packet)
	{
		this.packet = packet;
	}

	public void read(DataInputStream input) throws IOException
	{
		this.packet = new byte[input.available()];
		input.read(this.packet, 0, this.packet.length);
	}

	public void write(DataOutputStream output) throws IOException
	{
		output.write(this.packet, 0, this.packet.length);
	}

}
